/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "local")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Local.findAll", query = "SELECT l FROM Local l"),
    @NamedQuery(name = "Local.findByIdLocal", query = "SELECT l FROM Local l WHERE l.idLocal = :idLocal"),
    @NamedQuery(name = "Local.findByName", query = "SELECT l FROM Local l WHERE l.name = :name"),
    @NamedQuery(name = "Local.findByAddress", query = "SELECT l FROM Local l WHERE l.address = :address"),
    @NamedQuery(name = "Local.findByPostcode", query = "SELECT l FROM Local l WHERE l.postcode = :postcode"),
    @NamedQuery(name = "Local.findByCoordinatex", query = "SELECT l FROM Local l WHERE l.coordinatex = :coordinatex"),
    @NamedQuery(name = "Local.findByCoordinatey", query = "SELECT l FROM Local l WHERE l.coordinatey = :coordinatey"),
    @NamedQuery(name = "Local.findByDesc", query = "SELECT l FROM Local l WHERE l.desc = :desc"),
    @NamedQuery(name = "Local.findByPhone", query = "SELECT l FROM Local l WHERE l.phone = :phone"),
    @NamedQuery(name = "Local.findByHourly", query = "SELECT l FROM Local l WHERE l.hourly = :hourly"),
    @NamedQuery(name = "Local.findByVotes", query = "SELECT l FROM Local l WHERE l.votes = :votes"),
    @NamedQuery(name = "Local.findByCreationDate", query = "SELECT l FROM Local l WHERE l.creationDate = :creationDate"),
    @NamedQuery(name = "Local.findByModifDate", query = "SELECT l FROM Local l WHERE l.modifDate = :modifDate"),
    @NamedQuery(name = "Local.findByIndActive", query = "SELECT l FROM Local l WHERE l.indActive = :indActive")})
public class Local implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_LOCAL")
    private Integer idLocal;
    @Size(max = 20)
    @Column(name = "NAME")
    private String name;
    @Size(max = 100)
    @Column(name = "ADDRESS")
    private String address;
    @Column(name = "POSTCODE")
    private Integer postcode;
    @Size(max = 10)
    @Column(name = "COORDINATEX")
    private String coordinatex;
    @Size(max = 10)
    @Column(name = "COORDINATEY")
    private String coordinatey;
    @Size(max = 250)
    @Column(name = "DESC")
    private String desc;
    @Column(name = "PHONE")
    private Integer phone;
    @Size(max = 50)
    @Column(name = "HOURLY")
    private String hourly;
    @Column(name = "VOTES")
    private Integer votes;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CREATION_DATE")
    @Temporal(TemporalType.DATE)
    private Date creationDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MODIF_DATE")
    @Temporal(TemporalType.DATE)
    private Date modifDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "IND_ACTIVE")
    private String indActive;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idLocal")
    private Collection<LocalImages> localImagesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idLocal")
    private Collection<LocalComment> localCommentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idLocal")
    private Collection<Offer> offerCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idLocal")
    private Collection<Suscriptions> suscriptionsCollection;
    @JoinColumn(name = "ID_TYPE", referencedColumnName = "ID_LOCAL_TYPE")
    @ManyToOne(optional = false)
    private LocalType idType;
    @JoinColumn(name = "ID_CITY", referencedColumnName = "ID_CITY")
    @OneToOne(optional = false)
    private City idCity;
    @JoinColumn(name = "ECONOMIC_TYPE", referencedColumnName = "ID_LOCAL_ECON_TYPE")
    @ManyToOne(optional = false)
    private LocalEconType economicType;
    @JoinColumn(name = "ID_COMPANY", referencedColumnName = "ID_COMPANY")
    @ManyToOne(optional = false)
    private Company idCompany;

    public Local() {
    }

    public Local(Integer idLocal) {
        this.idLocal = idLocal;
    }

    public Local(Integer idLocal, Date creationDate, Date modifDate, String indActive) {
        this.idLocal = idLocal;
        this.creationDate = creationDate;
        this.modifDate = modifDate;
        this.indActive = indActive;
    }

    public Integer getIdLocal() {
        return idLocal;
    }

    public void setIdLocal(Integer idLocal) {
        this.idLocal = idLocal;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getPostcode() {
        return postcode;
    }

    public void setPostcode(Integer postcode) {
        this.postcode = postcode;
    }

    public String getCoordinatex() {
        return coordinatex;
    }

    public void setCoordinatex(String coordinatex) {
        this.coordinatex = coordinatex;
    }

    public String getCoordinatey() {
        return coordinatey;
    }

    public void setCoordinatey(String coordinatey) {
        this.coordinatey = coordinatey;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Integer getPhone() {
        return phone;
    }

    public void setPhone(Integer phone) {
        this.phone = phone;
    }

    public String getHourly() {
        return hourly;
    }

    public void setHourly(String hourly) {
        this.hourly = hourly;
    }

    public Integer getVotes() {
        return votes;
    }

    public void setVotes(Integer votes) {
        this.votes = votes;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public Date getModifDate() {
        return modifDate;
    }

    public void setModifDate(Date modifDate) {
        this.modifDate = modifDate;
    }

    public String getIndActive() {
        return indActive;
    }

    public void setIndActive(String indActive) {
        this.indActive = indActive;
    }

    @XmlTransient
    public Collection<LocalImages> getLocalImagesCollection() {
        return localImagesCollection;
    }

    public void setLocalImagesCollection(Collection<LocalImages> localImagesCollection) {
        this.localImagesCollection = localImagesCollection;
    }

    @XmlTransient
    public Collection<LocalComment> getLocalCommentCollection() {
        return localCommentCollection;
    }

    public void setLocalCommentCollection(Collection<LocalComment> localCommentCollection) {
        this.localCommentCollection = localCommentCollection;
    }

    @XmlTransient
    public Collection<Offer> getOfferCollection() {
        return offerCollection;
    }

    public void setOfferCollection(Collection<Offer> offerCollection) {
        this.offerCollection = offerCollection;
    }

    @XmlTransient
    public Collection<Suscriptions> getSuscriptionsCollection() {
        return suscriptionsCollection;
    }

    public void setSuscriptionsCollection(Collection<Suscriptions> suscriptionsCollection) {
        this.suscriptionsCollection = suscriptionsCollection;
    }

    public LocalType getIdType() {
        return idType;
    }

    public void setIdType(LocalType idType) {
        this.idType = idType;
    }

    public City getIdCity() {
        return idCity;
    }

    public void setIdCity(City idCity) {
        this.idCity = idCity;
    }

    public LocalEconType getEconomicType() {
        return economicType;
    }

    public void setEconomicType(LocalEconType economicType) {
        this.economicType = economicType;
    }

    public Company getIdCompany() {
        return idCompany;
    }

    public void setIdCompany(Company idCompany) {
        this.idCompany = idCompany;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLocal != null ? idLocal.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Local)) {
            return false;
        }
        Local other = (Local) object;
        if ((this.idLocal == null && other.idLocal != null) || (this.idLocal != null && !this.idLocal.equals(other.idLocal))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Local[ idLocal=" + idLocal + " ]";
    }
    
}
